﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Marmat.Forms.Views.Grid;

namespace Marmat.Forms.Design
{
    public partial class GridControlColumnCollectionForm : Marmat.Forms.Design.CollectionEditorForm<Marmat.Forms.Views.Grid.Column>
    {
        public GridControlColumnCollectionForm(Marmat.Forms.Views.Grid.ColumnCollection columns) : base(columns)
        {
            InitializeComponent();
        }

        protected override Column NewItem(object sender, EventArgs e)
        {
            int count = this._collection.Count;
            do
            {
                count++;
                string columnName = $"第{count}列";
                if (this._collection.FirstOrDefault(x => x.Name == columnName) is null)
                {
                    Marmat.Forms.Views.Grid.Column column = new Marmat.Forms.Views.Grid.Column();
                    column.Name = columnName;
                    return column;
                }
            } while (true);
        }
    }
}
